package team.nmsg;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;

import team.nmsg.ge.system.util.ServerParams;


/**
 * NMS Publish System
 * @author user gdq
 *
 */
public class SysServerUI extends JFrame{

	private static SysServerUI serverUI = null;
	
	public String[] inputArgs ;
	
	public SysServerUI(String[] args){
		
		serverUI = this;
		inputArgs = args;
		
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		
		startSys();
	}
	
	private void startSys() {
		
		SysBootThread sysBootThread = new SysBootThread(serverUI);
		
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				int result = JOptionPane.showConfirmDialog(serverUI ,  ("Sure to shutdown the Server?") );
				if( 0 == result ){
					sysBootThread.shutdownSystem();
				}
			}
		});
		
		new Thread(sysBootThread, "SysBootThread").start();
		
	}
	

	public void initUI() {
		this.setSize(200, 200);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}

	public static void main(String[] args) {
		
		SysServerUI npsUI = new SysServerUI(args);
		
	}

	
}
